﻿using System.Collections.Generic;
using Dsl.Ped.AddIn.Java.Generated;

namespace Dsl.Ped.AddIn.Java.Helpers
{
    /// <summary>
    /// Helper methods of the collection of <see cref="Member"/> objects
    /// </summary>
    public static class MembersHelper
    {
        /// <summary>
        /// Converts the collection of <see cref="Member"/> objects into the plain text representation
        /// </summary>
        /// <param name="members">Collection of <see cref="Member"/> objects</param>
        /// <param name="className">Name of the class in which these members operates</param>
        /// <param name="tabs">Tabs representing an indent</param>
        /// <returns>String representing a collection of <see cref="Member"/> objects converted into a plain text</returns>
        public static string ToPlainText(this IEnumerable<Member> members, string className, int tabs)
        {
            var str = "";
            foreach (var member in members)
            {
                if (member is Constructor)
                {
                    str += (member as Constructor).ToPlainText(className, tabs);
                }
                else if (member is Field)
                {
                    str += (member as Field).ToPlainText(tabs);
                }
                else if (member is Method)
                {
                    str += (member as Method).ToPlainText(tabs);
                }
            }

            return str;
        }
    }
}
